-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle zip traversal vulnerability #92
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
Great job! I have created a fork in the meantime :) (some owner please merge it) |
This fix sometimes fails, presumably when outputDirectory is not itself canonical. |
can somebody merge this????? |
When the outputDirectory is a relative path you can convert it to a canonical path and still apply the same check. File file = new File(outputDirectory + compressedName);
String canonicalDestinationPath = (new File(outputDirectory)).getCanonicalPath();
String canonicalPath = file.getCanonicalPath();
if (!canonicalPath.startsWith(canonicalDestinationPath)) {
String errorMessage = "Zip traversal security error";
callbackContext.error(errorMessage);
Log.e(LOG_TAG, errorMessage);
return;
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's work!
Should this really be approved, if it fails when the |
@lczw I've tested the solution for both relative and full paths and it works for both. So far I have not encountered any weird behaviors. |
It's ok. ;)
czw., 16 gru 2021, 10:52 użytkownik David Talevski ***@***.***>
napisał:
… @lczw <https://github.com/lczw> I've tested the solution for both
relative and full paths and it works for both. So far I have not
encountered any weird behaviors.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#92 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCYCNLU3DNSNGZW53JLDFLURGZFBANCNFSM4WYKYZKA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
I see. I have encountered a problem where there was a mismatch which is fixed by getting the canonical path of the output directory. However, if it works on your end then it's probably something that should be fixed in my project instead of the plugin ^^ |
I was describing the getCanonicalPath solution. I also had an issue with the PR code with relative paths which got fixed when turning them to canonical, so the problem is most likely not on your end. |
I misunderstood your comment, sorry. Your code works fine for me as well, which is why I though it's a good idea to use it instead of the PR's code |
Following this proposal solution MobileChromeApps#92 (comment)
So is the final decision that this will not be merged? |
Hi devs, I've manually applied this fix into my code today and would like to share a note about the problem. The fix was applied to an Android APP (Ionic v3 / Angular) that uses the cordova-plugin-zip lib. After apply the fix and test the APP, I noticed that the zip content that I had into my APP was not being unzipped, and while checking logs with adb logcat, I saw the message "Zip traversal security error" from the fix applied. After debug the problem, I saw that, in my APP, the output directory where the content was being extracted is the user directory inside the Android filesystem. Compare the directories below: Output from "file.getCanonicalPath()": My APP output directory (where the zip content would be extract to): Because of this, the code So, to be able to use the fix #92 and attend my scenario, I've added one more verification, as below:
Hope this can help someone. |
/data/data/foo vs /data/user/0/foo, as suggested by @jcperuffo in MobileChromeApps#92 (comment)
@jcperuffo we ran into the same problem & your solution worked. thanks! |
I think this is the fix we want. |
inspired by: * MobileChromeApps#92
Fixes #91 by checking the file path as described in this article